package com.grp6.game.mvc;

import static org.junit.Assert.*;

import java.util.List;

import javax.swing.UIManager;

import org.junit.Test;

import com.grp6.game.controller.GameLordTest.UIPlatformFactoryMock;
import com.grp6.game.model.AbstractObservableModel;
import com.grp6.game.model.IModel;
import com.grp6.game.ui.platform.IAbstractUIPlatformFactory;
import com.grp6.game.ui.platform.IActionListener;
import com.grp6.game.ui.platform.ICell;
import com.grp6.game.view.AbstractCellView;

public class ModelViewTest {
	
	private class AbstractCellViewMock extends AbstractCellView<AbstractObservableModelMock>{
		private boolean gotUpdate = false;
		@Override
		public void update() {
			gotUpdate = true;
		}
	}
	
	private class AbstractObservableModelMock extends AbstractObservableModel<AbstractCellViewMock>{
		@Override
		public void actionPerformed(String actionName) {
			// TODO Auto-generated method stub
			
		}}
	
	@Test
	public void testNotify() {
		AbstractObservableModelMock model = new AbstractObservableModelMock();
		AbstractCellViewMock view = new AbstractCellViewMock();
		view.setModel(model);
		model.notifyObservers();
		assertTrue(view.gotUpdate);
	}
	
	@Test
	public void testGetCells() {
		AbstractCellViewMock view = new AbstractCellViewMock();
		assertNotNull(view.getCells());
	}
	
	@Test
	public void testX() {
		AbstractObservableModelMock model = new AbstractObservableModelMock();
		AbstractCellViewMock view = new AbstractCellViewMock();
		view.setModel(model);
		assertNotNull(view.getModel());
	}
	
	@Test
	public void testY() {
		AbstractObservableModelMock model = new AbstractObservableModelMock();
		AbstractCellViewMock view = new AbstractCellViewMock();
		view.setModel(model);
		assertNotNull(model.getObservers());
		assertTrue(model.getObservers().size()>0);
	}
	
	@Test
	public void testAddCell() {
		AbstractCellViewMock view = new AbstractCellViewMock();
		ICell cell = new ICellMock();
		view.addCell(cell);
		cell.addActionListerner(view.getModel());
	}
	
	class ICellMock implements ICell{

		@Override
		public void addActionListerner(IActionListener listener) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void setHighlight(boolean on) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void setSymbol(String symbol) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void setTile(String style) {
			// TODO Auto-generated method stub
			
		}
		
	
	}
}
